package com.example.design01.controller;

import com.example.design01.Bean.AttendanceBean;
import com.example.design01.Service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class AttendanceController {

    @Autowired
    private AttendanceService attendanceService;
//    请假记录
    @RequestMapping("/checkAttendance")
    public String checkAttendance(Model model){
        List<AttendanceBean> attendanceBeans = attendanceService.checkAttendance();
        model.addAttribute("aB",attendanceBeans);
        return "attendance";

    }
//    添加请假跳转
    @RequestMapping("/toAddAttendance")
    public String toAddAttendance(){
        return "addAttendance";
    }

//    添加请假
    @RequestMapping("/AddAttendance")
    public String AddAttendance(AttendanceBean attendanceBean){
        attendanceService.addAttendance(attendanceBean);
        return "redirect:/checkAttendance";
    }
}
